package com.mrazola;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.view.SurfaceHolder;

public class Space {
	
	//TODO Change to Rect
	public int width;
	public int height;
	public int centerX;
	public int centerY;

	private Rect frame;
	private Bitmap background;
	private Paint black = new Paint();
	
	//TODO Absurd to have a constructor which only calls init. Check if init is necessary.
	public Space(SurfaceHolder universe, Context context) {
		init(universe, context);
	}
	
	public void init(SurfaceHolder universe, Context context) {
		frame = universe.getSurfaceFrame();
		width = frame.width();
		height = frame.height();
		centerX = frame.centerX();
		centerY = frame.centerY();
		
		Canvas sky = universe.lockCanvas(frame);
		background = ((BitmapDrawable) context.getResources().getDrawable(R.drawable.circuit_board)).getBitmap();
		sky.drawBitmap(background, 0, 0, null);
		universe.unlockCanvasAndPost(sky);
	}
	
	public Rect getDirtyArea() {
		return frame;
	}

	//TODO Black paint constant
	public void updateBackgroundState(Canvas sky, long elapsedTime) {
		sky.drawBitmap(background, 0, 0, null);
		//sky.drawRect(frame, black);
	}
	
}
